home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: delta / whiteline CD Series - delta.iso / tex / style / misc / color.sty < prev    next >
Text File  |  1995-11-25  |  13KB  |  327 lines

  1. \def\fileversion{v1}
  2. \def\filedate{91/12/04}
  3. \immediate\write\sixt@@n{File: `color.sty' 
  4. \fileversion\space <\filedate> (SPQR, from LL)}
  5. % Sebastian Rahtz
  6. % 5 Granary Court
  7. % St Andrewgate
  8. % York Y01 2JR
  9. %
  10. %spqr@uk.ac.soton.ecs
  11. % what this really is!
  12. %----------------------------------------
  13. % COLOR.DOC, 21 March 1990
  14. % derived from 
  15. % PS-SLIDES DOCUMENT -- released  14 November 1989
  16. %    for SliTeX version 2.09
  17. % Copyright (C) 1988 by Leslie Lamport
  18. % \typeout{`color' -- released <21 Mar 90>}
  19.  
  20. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  21. %                         ABOUT THIS DOCUMENT STYLE                         %
  22. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  23. % This style puts \special commands in the .dvi file that, when printed     %
  24. % on the proper color printer, produces colored output.  It is currently    %
  25. % configured to work when the .dvi file is run through the dvips program,   %
  26. % or dvitops. See the case statement that follows.
  27. %
  28. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  29.  
  30. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  31. %             DIFFERENCES BETWEEN color.sty AND ORDINARY SLiTeX             %
  32. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  33. %
  34. % * The \colors command is made a no-op. Colors that are not predefined
  35. %    must be defined with the \newpscolor command (see below).
  36. % * The \colorslides and \blackandwhite commands are the same, except that
  37. %   \colorslides prints only slides and overlays, not notes.
  38. % * The meaning of the \invisible declaration has been changed, as described
  39. %   below.  The old \visible command is the same as the new \white command.
  40. % * The default page style is `plain'.  (The alignment marks are no longer
  41. %   of any use.)
  42. %
  43. % * The positioning of the body of the slide and the slide number have
  44. %   been changed to accomodate the QMS printer's small effective page 
  45. %   size.
  46. %
  47. % Except for these differences, a SLiTeX input file prepared for the
  48. % ordinary `slides' style SHOULD work with the `ps-slides' style.  There
  49. % are probably some SLiTeX commands that will interact incorrectly with
  50. % color-changing commands.  These problems will be corrected when
  51. % reported.  The most likely bug is a color declaration `escaping from
  52. % its scope', having a more global effect than it should.  Such a problem
  53. % can be worked around by adding redundant color-changing commands.
  54.  
  55.  
  56. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  57. %                           THE \special COMMAND                            %
  58. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  59. %                                                                           %
  60. % \@drawcolor produces a \special command that sets the printer's color     %
  61. % to the RGB value indicated by the control sequences \@red, \@green,       %
  62. % and \@blue.  This command must be changed to customize the document       %
  63. % style to work under other systems
  64. %                                                                           %
  65.                                                                            %
  66. \@ifundefined{driver@setup}%
  67. {
  68. \typeout{WARNING *** driver setup codes are unknown in this setup ***}
  69. \typeout{*** No color changes ***}
  70. \def\@drawcolor{}
  71. }
  72. {
  73. \typeout{Driver type \the\driver@setup}
  74. % 0. dvi2lj: no rotation possible
  75. % 1. dvi2ps (Les Carr)
  76. % 2. dvitops (James Clark)
  77. % 3. dvips (Tom Rokicki)
  78. \ifcase\driver@setup
  79. % case 0  not available
  80. \typeout{WARNING *** A color mechanism is not defined for this setup ***}
  81. \def\@drawcolor{}
  82. \or % case 1
  83. \typeout{WARNING *** A color mechanism is not defined for this setup ***}
  84. \def\@drawcolor{}
  85. \or  % case 2 (dvitops, Adobe-encoded)
  86. \newcount\regionno
  87. \def\@drawcolor{%
  88. \special{dvitops: begin \the\regionno}%
  89. \special{dvitops: rgbcolor \the\regionno\space \@red\space \@green\space \@blue}%
  90. \global\advance\regionno by 1
  91. }
  92. \or % case 3 (dvips, Rokicki, virtual fonts)
  93. \def\@drawcolor{\special{ps: \@red\space \@green\space                        %
  94.                      \@blue\space setrgbcolor\space}}                       %
  95. \else                                                                       %
  96. \typeout{WARNING *** This driver setup is unknown - no color mechanism ***}
  97. \def\@drawcolor{}
  98. \fi
  99. }
  100. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  101. %                         NEW AND CHANGED COMMANDS                          %
  102. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  103. % \newpscolor{\PUCE}{RED}{GREEN}{BLUE} 
  104. % \renewpscolor{\PUCE}{RED}{GREEN}{BLUE} 
  105. %
  106. %       Define \PUCE to produce a new color with the indicated RGB values,
  107. %       where RED, GREEN, and BLUE are decimal numbers between 0 and 1
  108. %       (inclusive).  For example:
  109. %            Black         =  [RED: 0,  GREEN: 0,  BLUE: 0]
  110. %            White         =  [RED: 1,  GREEN: 1,  BLUE: 1]
  111. %            Red           =  [RED: 1,  GREEN: 0,  BLUE: 0]
  112. %            Light yellow  =  [RED: .5, GREEN: .5, BLUE: 0]
  113. %      For \newpscolor \PUCE must not already be defined; for
  114. %      \renewpscolor, it must already be defined (but not necessarily as a
  115. %      color).
  116. %
  117. %
  118. % The following colors are predefined:
  119. %
  120. %      \black, \red, \green, \blue, \yellow, \magenta, \cyan, \white
  121. %
  122. % For ordinary printers, which assume white paper, \white text is invisible.
  123. % Unlike in ordinary SLiTeX, color-changing commands can be used in
  124. % math mode.
  125. %
  126. %
  127. % \invisible 
  128. % \visible   
  129. %
  130. %      Ordinary declarations of visibility of the text.  Invisible text
  131. %      is not printed.  (TeX prints it in a font that whose letters are all
  132. %      print as spaces.)
  133. %      Visibility is independent of color, so you can have invisible red text,
  134. %      visible green text, and even visible white text.  (Visible white text
  135. %      can be seen only when printed by a weird printer that prints on
  136. %      nonwhite paper.)
  137. %
  138. % \norestore
  139. % \restore
  140. %      The \norestore declaration inhibits the proper scoping of color
  141. %      declarations, causing color declarations to act as if they were global.
  142. %      The \restore command causes the current and future colors to become the
  143. %      ones they would have been had there been no \norestore command.
  144. %      Both \norestore and \restore are global declarations.  Example:
  145. %      
  146. %        \black black {\green green 
  147. %                             \norestore {\red red} red
  148. %                             \restore 
  149. %                             green} 
  150. %               black
  151. %      
  152. %      The \norestore declaration is handy for color commands inside a tabbing
  153. %      or tabular environment.  However, there are some anomalies: 
  154. %      
  155. %       * A \restore command inside a tabbing environment may not work exactly
  156. %         as it should.  Try putting the command immediately after a \=, \\, or
  157. %         \>.  
  158. %      
  159. %       * An \fbox, \framebox, or \frame command may do weird things in the
  160. %         scope of a \norestore if there's a color declaration in its argument.
  161. %      
  162. %       * A \background  may behave strangely inside the scope of a \norestore.
  163. %
  164. %
  165. % \background{\yellow}{TEXT} 
  166. %      
  167. %      Typesets TEXT in an \mbox with a yellow box behind it.  The yellow box
  168. %      is the width of TEXT plus a border of width \bgborder around it.
  169. %
  170. %
  171. % \hollowbackground 
  172. % \filledbackground 
  173. %      
  174. %      A \hollowbackground declaration causes any \background command in its
  175. %      scope to produce an outline, much like \fbox, instead of a filled box.
  176. %      This is useful for checking the slides with Proof or on a
  177. %      black-and-white printer.  A \filledbackground declaration has the
  178. %      opposite effect.
  179. %
  180. %
  181. % \nogray 
  182. %      
  183. %      A declaration that makes every color other than \white be equivalent to
  184. %      \black, and issues a \hollowbackground declaration
  185. %
  186. % \norestore and \restore 
  187. %
  188. \def\norestore{\gdef\@aftergroup{}}
  189. \def\restore{\gdef\@aftergroup{\@drawcolor}\@drawcolor}
  190. %
  191. % \@setcolor{RED}{GREEN}{BLUE} sets the current RGB value within SLiTeX
  192. % and calls \@drawcolor to produce the PostScript commands to change
  193. % their values in the output.
  194. %
  195. \def\@setcolor#1#2#3{\edef\@red{#1}\edef\@green{#2}\edef\@blue{#3}\@drawcolor
  196.   \aftergroup\@aftergroup}
  197.  
  198. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  199. %
  200. % \newpscolor{\PUCE}{RED}{GREEN}{BLUE} :
  201. %    defines \PUCE to produce a new color with the indicated RGB values.
  202. %    \PUCE must not already be defined.
  203. % \renewpscolor{\PUCE}{RED}{GREEN}{BLUE} :
  204. %    same as \newpscolor but assumes \PUCE is already defined.
  205. %
  206. \def\newpscolor#1#2#3#4{\newcommand{#1}{\@setcolor{#2}{#3}{#4}}}
  207. \def\renewpscolor#1#2#3#4{\renewcommand{#1}{\@setcolor{#2}{#3}{#4}}}
  208.  
  209.  
  210. %% DEFINE SOME STANDARD COLORS
  211. \newpscolor{\black}{0}{0}{0}
  212. \newpscolor{\red}{1}{0}{0}
  213. \newpscolor{\yellow}{1}{1}{0}
  214. \newpscolor{\magenta}{1}{0}{1}
  215. \newpscolor{\green}{0}{1}{0}
  216. \newpscolor{\cyan}{0}{1}{1}
  217. \newpscolor{\blue}{0}{0}{1}
  218. \newpscolor{\white}{1}{1}{1}
  219.  
  220.  
  221.  
  222. % REDEFINE \colorslides SO IT PRODUCES ONLY SLIDES, NO NOTES,
  223. % AND WITHOUT ANY COLOR LAYER
  224.  
  225. \def\colorslides#1{\newpage\setcounter{page}{0}\@bwtrue\@visibletrue
  226. \if@onlyslidesw \xdef\@doslidelist{\@doglslidelist}%
  227. \@setlimits\@doslidelist\@doslidelow\@doslidehigh\fi
  228. \xdef\@doglnotelist{999998,999999,999999}%
  229. \xdef\@donotelist{\@doglnotelist}%
  230. \@setlimits\@donotelist\@donotelow\@donotehigh\@onlynoteswtrue
  231. \normalsize\setcounter{slide}{0}\setcounter{overlay}{0}%
  232. \setcounter{note}{0}\@makingslidestrue\input #1\@makingslidesfalse}
  233.  
  234. % REDEFINE \colors TO BE A NO-OP
  235. \def\colors#1{}
  236.  
  237. % Change to bowels of tabular environment needed to fix a bug that occurs
  238. % when a color command occurs in the last element.
  239. %
  240. \def\@tabclassz{\ifcase \@lastchclass \@acolampacol \or \@ampacol \or
  241.    \or \or \@addamp \or
  242.    \@acolampacol \or \@firstampfalse \@acol \fi
  243. \edef\@preamble{\@preamble
  244.   \ifcase \@chnum 
  245.      \hfil{\ignorespaces\@sharp\unskip}\hfil 
  246.      \or {\ignorespaces\@sharp\unskip}\hfil 
  247.      \or \hfil\hskip\z@ {\ignorespaces\@sharp\unskip}\fi}}
  248.  
  249.  
  250. % The following modify the tabbing environment to get the scope of the
  251. % color commands to be the same as for other declarations in a tabbing
  252. % environment.
  253. %
  254. \def\@startfield{\global\setbox\@curfield\hbox\bgroup\begingroup}
  255. \def\@stopfield{\endgroup\egroup}
  256. \def\@contfield{\global\setbox\@curfield\hbox\bgroup\begingroup
  257.    \unhbox\@curfield}
  258.  
  259. \def\visible{\@mmodetest\@visibletrue\@currsize\@currfont
  260.    \white\ignorespaces}
  261. \let\visible=\visible
  262. \let\endvisible=\relax
  263.  
  264. % The following modifies \fbox to make it work right with color commands.  
  265. % However, \fbox, \framebox, and \frame will do weird things
  266. % if \norestore is in effect.
  267. %
  268. \long\def\fbox#1{\leavevmode\setbox\@tempboxa\hbox{#1}\@tempdima\fboxrule
  269.     \advance\@tempdima \fboxsep \advance\@tempdima \dp\@tempboxa
  270.    \hbox{\lower \@tempdima\hbox
  271.   {\vbox{\if@visible \hrule \@height \else \vskip\fi\fboxrule 
  272.           \hbox{\if@visible\vrule \@width \else \hskip \fi\fboxrule 
  273.                  \hskip\fboxsep
  274.         \vbox{\vskip\fboxsep \box\@tempboxa\@aftergroup
  275.                     \vskip\fboxsep}\hskip 
  276.                    \fboxsep \if@visible\vrule \@width\else\hskip \fi\fboxrule}
  277.            \if@visible\hrule \@height \else \vskip \fi\fboxrule}}}}
  278.  
  279.  
  280. % The command \background{\yellow}{TEXT} typesets TEXT in an \mbox with a
  281. % yellow box behind it.  The yellow box is the width of TEXT plus a
  282. % border of width \bgborder around it.
  283. %
  284. % The declaration \hollowbackground causes any \background command in its
  285. % scope to produce an outline, much like \fbox, instead of a filled box.
  286. % The declaration \filledbackground has the opposite effect.
  287. %
  288. %
  289. \newsavebox{\@bgbox}
  290. \newlength{\bgborder}
  291. \bgborder=3pt\relax
  292. \newif\if@hollowbg \@hollowbgfalse
  293. \newcommand{\hollowbackground}{\@hollowbgtrue}
  294. \newcommand{\filledbackground}{\@hollowbgfalse}
  295. \newcommand{\background}[2]{\sbox{\@bgbox}{#2}%
  296. \@tempdima=\ht\@bgbox \advance\@tempdima \dp\@bgbox
  297.  \advance\@tempdima 2\bgborder
  298.  \@tempdimb=\wd\@bgbox \advance\@tempdimb2\bgborder
  299.  \makebox[0pt][l]{#1\raisebox{-\dp\@bgbox}
  300.  {\raisebox{-\bgborder}{\if@hollowbg
  301. \frame{\invisible\rule{\@tempdimb}{\@tempdima}}\else
  302.  \rule{\@tempdimb}{\@tempdima}\fi}}}%
  303. \hspace*{\bgborder}\box\@bgbox\@aftergroup{\hspace*{\bgborder}}}
  304.  
  305. % \nogray is a declaration that converts every color other than \white
  306. % to be equivalent to \black, and issues a \hollowbackground declaration
  307. %
  308. \let\@@setcolor=\@setcolor
  309. \def\nogray{\def\@setcolor##1##2##3{\@@setcolor{0}{0}{0}}
  310. \def\white{\@@setcolor{1}{1}{1}}\hollowbackground }
  311.  
  312. %% INITIALIZATION
  313. %
  314. \def\@red{0}
  315. \def\@green{0}
  316. \def\@blue{0}
  317. \gdef\@aftergroup{\@drawcolor}
  318. \@drawcolor
  319. %
  320. \endinput
  321.